#include <logger.h>
#include "modbusdevice.h"

#define VERSION "V1.00"

extern "C" {

    IDevice * CreateDevice(const char *protocol, uint16_t bay_id, uint16_t dev_id, IPhyLink *phy_dev)
    {
        if (strcmp(protocol, "modbus") == 0)
            return new ModbusDevice(bay_id, dev_id, phy_dev);

        log_info("not support protocol:%s\n", protocol);
        return nullptr;
    }

    void ReleaseDevice(IDevice *dev)
    {
        if (dev) {
            delete dev;
        }
    }

    const char * GetVersion(void)
    {
        static std::string ver;
        if (ver.empty()) {
            ver = VERSION ",";
            ver += __DATE__ "," __TIME__;
        }
        return ver.c_str();
    }
}
